{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "under-purse",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/monotonic-array\n",
    "\n",
    "\n",
    "Runtime: 52 ms, faster than 98.86% of C++ online submissions for Monotonic Array.\n",
    "Memory Usage: 52.7 MB, less than 71.94% of C++ online submissions for Monotonic Array.\n",
    "\n",
    "\n",
    "```cpp\n",
    "class Solution {\n",
    "public:\n",
    "    bool isMonotonic(vector<int>& A) {\n",
    "        //7:28\n",
    "        if (A.size() == 1) {\n",
    "            return true;\n",
    "        }\n",
    "        bool up = true;\n",
    "        bool down = true;\n",
    "        for(int i=0; i<A.size(); i++) {\n",
    "            if (i+1 < A.size()) {\n",
    "                if (!(A[i] <= A[i+1])) {\n",
    "                    up = false;\n",
    "                }\n",
    "                if (!(A[i] >= A[i+1])) {\n",
    "                    down = false;\n",
    "                }\n",
    "            }\n",
    "        }\n",
    "        return up or down;\n",
    "        //7:30\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "expected-mother",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
